/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.article.entity;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

import org.hibernate.validator.NotNull;
import org.hibernate.validator.Size;

/**
 *
 * @author Tsingheng
 */
@Entity
@Table(name = "tree_node")
@NamedQueries({
    @NamedQuery(name = "TreeNode.findAll", query = "SELECT t FROM TreeNode t")})
public class TreeNode implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @NotNull
    @Column(name = "id")
    private Integer id;
    @Size(max = 100)
    @Column(name = "text")
    private String text;
    @Column(name = "parent_id")
    private Integer parentId;
    @Column(name = "leaf")
    private Boolean leaf;
    @Size(max = 100)
    @Column(name = "link_url")
    private String linkUrl;
    @Size(max = 100)
    @Column(name = "icon_cls")
    private String iconCls;

    public TreeNode() {
        this.id = 1;
    }

    public TreeNode(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    public Integer getParentId() {
        return parentId;
    }

    public void setParentId(Integer parentId) {
        this.parentId = parentId;
    }

    public Boolean getLeaf() {
        return leaf;
    }

    public void setLeaf(Boolean leaf) {
        this.leaf = leaf;
    }

    public String getLinkUrl() {
        return linkUrl;
    }

    public void setLinkUrl(String linkUrl) {
        this.linkUrl = linkUrl;
    }

    public String getIconCls() {
        return iconCls;
    }

    public void setIconCls(String iconCls) {
        this.iconCls = iconCls;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof TreeNode)) {
            return false;
        }
        TreeNode other = (TreeNode) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.article.entity.TreeNode[ id=" + id + " ]";
    }
    
}
